import * as React from "react";

class MyTest extends React.Component<{time: any}> {
    constructor(props: any) {
        console.log(props);
        super(props);
        this.state = {}
    }

    static getDerivedStateFromProps(nextProps: any, prevState: any) {
        console.log('nextProps', nextProps);
        console.log('prevState', prevState);
        // const {type} = nextProps;
        // 当传入的type发生变化的时候，更新state
        // if (type !== prevState.type) {
        //     return {
        //         type,
        //     };
        // }
        // 否则，对于state不进行任何操作
        // return null;
        return null;
    }

    public render() {
        return (
            <div className="App">
                {this.props.time}
            </div>
        );
    }
}

export default MyTest;